/**
 * 处理请求路径分发
 * 1. req对象是class：http.IncomingMessage的实例对象
 * 2. res对象是class：http.ServerResponse的实例对象
 */

const http = require('http');

let server = http.createServer();

server.on('request', (req, res) => {
    //res.end(req.url);
    if (req.url.startsWith('/index')) {
        //write向客户端响应内容，可以写多次
        res.write('hello');
        res.write('hi');
        res.write('nihao');
        res.end('index');
    } else if (req.url.startsWith('/about')) {
        res.end('about');
    } else {
        res.end('no content');
    }
});

server.listen(3000, '192.168.0.168', () => {
    console.log('running ........')
});